package com.haixinga.commbiz.mgr.filters;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/** Filter 过滤器配置项 **/
@Configuration
public class MyFilterConfig {

    @Bean
    public FilterRegistrationBean<AuthFilter> authFilterRegistration() {

        //暂定 [ /api/* ] 全部需要鉴权， 其他均无需鉴权，约定大于配置， 起名规则为[ /anno/**/* ] (anonymous简写)
        FilterRegistrationBean<AuthFilter> registration = new FilterRegistrationBean<>();
        registration.addUrlPatterns("/api/*");  //url-pattern
        registration.setName("authFilter"); //过滤器名称
        registration.setOrder(1);  //顺序
        registration.setFilter(new AuthFilter()); //过滤器类
        return registration;
    }

}
